<template>
 <div class="app-container">
   <el-form style="float:left">
    <el-form-item label="手机号" :label-width="formLabelWidth" class="input">
      <el-input v-model="phoneNum" placeholder="请输入手机号"></el-input>
    </el-form-item>
    <el-form-item label="时间查询" :label-width="formLabelWidth" class="input">
      <el-date-picker
        v-model="dateArr"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
      </el-date-picker>
    </el-form-item>
    </el-form>
    <el-button type="primary" icon="el-icon-search" style="float:left;margin-left:10px" @click="getAccountList">查询</el-button>
    <el-table :data="accountData" border style="width: 100%" class="couponTable">
      <!--<el-table-column prop="userId"             label="用户ID"         min-width="160"></el-table-column>-->
      <el-table-column prop="phoneNum"         label="手机号"          ></el-table-column>
      <el-table-column prop="amount"          label="发生额"        ></el-table-column>
      <el-table-column prop="leftAmount"     label="账户余额"        ></el-table-column>
      <el-table-column prop="channelInfo"         label ="渠道来源"        ></el-table-column>
      <!--<el-table-column prop="flowType"        label="类型"       ></el-table-column>-->
      <!--<el-table-column prop="accountFlowId"         label="交易流水号"       min-width="180"></el-table-column>-->
      <el-table-column prop="dateCreated"       label="交易时间"       min-width="100"></el-table-column>
      <el-table-column prop="tranDesc"               label="备注"   ></el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="curPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="size">
      </el-pagination>
    </div>
 </div>
</template>
<script>
import { getAccountFlowAll } from 'api/account'
import moment from 'moment'
export default {
  data() {
    return {
      accountData: [],
      pageSize: 10,
      curPage: 1,
      size: 0,
      phoneNum: '',
      formLabelWidth: '120px',
      dateArr: []
    }
  },
  created() {
    this.getAccountList()
  },
  methods: {
    async getAccountList() {
      const parm = {
        pageSize: this.pageSize,
        curPage: this.curPage - 1,
        phoneNum: this.phoneNum,
        queryStart: '',
        queryEnd: ''
      }
      if (this.dateArr == null || this.dateArr.length === 0) {
        console.log('aa')
      } else {
        parm.queryStart = moment(this.dateArr[0]).format('YYYY-MM-DD')
        parm.queryEnd = moment(this.dateArr[1]).format('YYYY-MM-DD')
      }
      try {
        let back = await getAccountFlowAll(parm)
        back = back.data
        if (back.resultCode === '200') {
          this.accountData = back.result
          this.size = back.size
        }
      } catch (err) {
        this.$alert('出错了' + err, '提示')
      }
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.getAccountList()
    },
    handleCurrentChange(val) {
      this.curPage = val
      this.getAccountList()
    }
  }
}
</script>
<style scoped lang="scss">
  .block{
    margin-top:20px;
    float: right;
  }
  .input{
    float: left;
  }
</style>
